package com.suql.kotlin

import android.app.Activity
import android.util.Log
import android.widget.Toast
import com.suql.networktools.net.RxHelper

class Singleton private constructor(){

    val TAG = Singleton::class.java.simpleName
    // 伴随对象
//    companion object {
//        // by lazy {} 懒加载，用的时候再创建对象
//        val instance: Singleton by lazy { Singleton() }
//    }

    private object RxHelperHolder {
        val instance = Singleton()
    }

    companion object {
        fun getInstance() = RxHelperHolder.instance
    }

    fun test(activity: Activity) {
//        Log.e(TAG, "test")
        Toast.makeText(activity, "单例：test", Toast.LENGTH_SHORT).show()
    }
}